﻿//========================================================= 
/**@file ComSLE4428.h 
 * @brief 串口4428卡驱动 
 * 
 * @date 2014-10-21   20:40:57 
 * @author Zhyioo 
 * @version 1.0
 */ 
//--------------------------------------------------------- 
#ifndef _LIBZHOUYB_COMSLE4428_H_
#define _LIBZHOUYB_COMSLE4428_H_
//--------------------------------------------------------- 
#include "../base/IMemoryCard.h"
using namespace zhou_yb::device::iccard::extension::base;

#include "../../device/ComStorageCardDevAdapter.h"
using zhou_yb::device::iccard::device::ComContactStorageCardDevAdapter;
//--------------------------------------------------------- 
namespace zhou_yb {
namespace device {
namespace iccard {
namespace extension {
namespace device {
//--------------------------------------------------------- 
/// COM设备4428卡驱动
class ComSLE4428 : 
    public ISLE4428,
    public ComContactStorageCardDevAdapter
{
protected:
    //----------------------------------------------------- 
    /// 临时缓冲区
    ByteBuilder _tmpBuffer;
    //----------------------------------------------------- 
public:
    //----------------------------------------------------- 
    /// 设备所能识别的卡片类型
    enum _CardType
    {
        /// 卡片类型标识 
        CardType = ComContactStorageCardDevAdapter::Card_SLE44x8
    };
    //----------------------------------------------------- 
    //@{
    /**@name 
     * @brief IMemoryCard成员函数 
     */ 
    /// 校验密码(用户密码)
    virtual bool VerifyKey(const ByteArray& key)
    {
        LOG_FUNC_NAME();
        LOGGER(_log << "密钥:<";
        _log.WriteStream(key) << ">\n");
        ASSERT_FuncErrInfoRet(key.GetLength() == ISLE4428::KeyLength, DeviceError::ArgLengthErr, "密钥长度错误");
        return _logRetValue(ComContactStorageCardDevAdapter::VerifyKey(key));
    }
    /// 读数据 
    virtual bool ReadMemory(size_t adr, size_t len, ByteBuilder& buff)
    {
        return ComContactStorageCardDevAdapter::ReadMemory(static_cast<ushort>(adr), static_cast<ushort>(len), buff);
    }
    /// 写数据 
    virtual bool WriteMemory(size_t adr, const ByteArray& buff)
    {
        return ComContactStorageCardDevAdapter::WriteMemory(static_cast<ushort>(adr), buff);
    }
    //@}
    //----------------------------------------------------- 
};
//--------------------------------------------------------- 
} // namespace device
} // namespace extension
} // namespace iccard
} // namespace device
} // namespace zhou_yb
//--------------------------------------------------------- 
#endif // _LIBZHOUYB_COMSLE4428_H_
//========================================================= 